
    <div id="div_liste_reglement" class="row-fluid">
        <div class="span12">
            <div class="box gradient">
                <div class="title" style="text-align: center">
                    <h4>Liste Reglement Fournisseur</h4>
                </div>
                <div id="div-list-user" class="content noPad clearfix">
                    <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
                        <div id="DataTables_Table_0_filter" class="dataTables_filter">
                            <div class="span2" style="margin-left: 10px">
                                <label style="width: 100%"> Departement:</label>
                                        {{ render(controller('GdsVenteBundle:Devis:getAllDepartement')) }}
                                        
                                    </div>
                                <div class="span2" style="margin-left: 10px">
                                        <label style="width: 100%"> 
                                            Raison Social:</label>
                                        {{ render(controller('GdsAchatBundle:Fournisseur:getAllFournissuer')) }}
                                        
                                        </div>
                                <div class="span2" style="margin-left: 10px">
                                <label style="width: 100%"> 
                                            N° Reglement:</label>
                                            <input class="text" type="text" id="filtre_numero" style="width:80%;margin-left: 0"/>
                                        
</div>
                                <div class="span2" style="margin-left: 10px">
                                        <label style="width: 100%"> 
                                            Date:</label>
                                            <input class="text" type="text" id="filtre_date1" style="width:80%;margin-left: 0"/>
                                        
                                        </div>
                                <div class="span2" style="margin-left: 10px">
                                    <label style="width: 100%"> 
                                            Jusqu'à:</label>
                                            <input class="text" type="text" id="filtre_date2" style="width:80%;margin-left: 0" />
                                        
                                    </div>
                                <div class="span2" style="margin-left: 10px">
                                <label style="width: 100%"> 
                                            Heure:</label>
                                            <select id="filtre_heure" class="nostyle"  style="width:80%;margin-left: 0"required="required">
                                                <option value="1"></option>
                                                <option value="2">07h -> 12h</option>
                                                <option value="3">12h -> 21h</option>
                                                <option value="4">08h -> 10h</option>
                                                <option value="5">10h -> 12h</option>
                                                <option value="6">12h -> 14h</option>
                                                <option value="7">14h -> 16h</option>
                                                <option value="8">16h -> 18h</option>
                                                <option value="9">18h -> 20h</option>
                                                <option value="10">20h -> 22h</option>
                                            </select>
                                        
                                        </div>
                                <div class="span2" style="margin-left: 10px">
                                    <label style="width: 100%"> 
                                            Reference Bon Livraison:</label>
                                            <input class="text" type="text" id="filtre_ref_b" style="width:80%;margin-left: 0"/>
                                        
                                    </div>
                                <div class="span2" style="margin-left: 10px">
                                <label style="width: 100%"> 
                                            Reference Facture:</label>
                                            <input class="text" type="text" id="filtre_ref_f" style="width:80%;margin-left: 0"/>
                                        
                                    </div>
                                <div class="span2" style="margin-left: 10px">
                                        <label style="width: 100%"> 
                                            TTC entre:</label>
                                            <input class="text" type="text" id="filtre_ttc1" style="width:80%;margin-left: 0"/>
                                        
</div>
                                <div class="span2" style="margin-left: 10px">
                                        <label style="width: 100%"> 
                                            ET:</label>
                                            <input class="text" type="text" id="filtre_ttc2" style="width:80%;margin-left: 0"/>
                                        
</div>
                        </div>


                        <div id="liste_reglement">
                {% include 'GdsAchatBundle:Reglement:page_liste_reglement.html.twig' %}
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- End .box -->

        </div><!-- End .span12 -->

        <script>
            $(document).ready(function() {
                height_max=0;
                $('.span2').each(function(){
                    height=$(this).css('height') 
                    height=height.split('px')
                    height=height[0]
                    if(height_max<height)
                        height_max=height
                })
                $('.span2').css('height',height_max+'px')
                heure1 = ''
                heure2 = ''
                date1 = ''
                date2 = ''
                var fullDate = new Date();
                var twoDigitMonth = fullDate.getMonth()
                twoDigitMonth++
                twoDigitMonth += "";
                if (twoDigitMonth.length == 1)
                    twoDigitMonth = "0" + twoDigitMonth;
                var twoDigitDate = fullDate.getDate() + "";
                if (twoDigitDate.length == 1)
                    twoDigitDate = "0" + twoDigitDate;
                var currentDate = twoDigitDate + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
                $("#filtre_date2").val(currentDate)
                $("#filtre_date1").val('')
                $('#filtre_heure').val(1)
                $('#filtre_numero').val('')
                $('#filtre_ref_f').val('')
                $('#filtre_ref_b').val('')
                $('#filtre_ttc1').val('')
                $('#filtre_ttc2').val('')
                $('#fournisseur').val(0)
                $('#departement').val({{departement}})
                date2 = changeFormatDate($('#filtre_date2').val())
            })
            $("#filtre_date1").datepicker({
                changeMonth: true,
                onClose: function(selectedDate) {
                    $("#filtre_date2").datepicker("option", "minDate", selectedDate);
                }
            });
            $("#filtre_date2").datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                onClose: function(selectedDate) {
                    $("#filtre_date1").datepicker("option", "maxDate", selectedDate);
                }
            });
            $('#filtre_heure').change(function() {
                heure = $("#filtre_heure option:selected").text();
                heure = heure.split('h')
                heure1 = heure[0] * 3600
                if (heure1 != 0) {
                    heure2 = heure[1]
                    heure2 = heure2.split('->')
                    heure2 = heure2[1] * 3600
                } else {
                    heure1 = ''
                    heure2 = ''
                }
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_numero').keyup(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#fournisseur').change(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_date1').change(function() {
                date1 = changeFormatDate($('#filtre_date1').val())
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_date2').change(function() {
                date2 = changeFormatDate($('#filtre_date2').val())
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_ref_b').keyup(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_ref_f').keyup(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_ttc1').keyup(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            $('#filtre_ttc2').keyup(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
           
            $('#departement').change(function() {
                goToPage('{{path(pagination.route)}}?type=ajax')
            })
            function goToPage(url) {
                $.ajax({
                    url: url,
                    data: '&type=ajax&numero=' + $('#filtre_numero').val() + '&fournisseur=' + $('#fournisseur').val()
                            + '&date1=' + date1 + '&date2=' + date2
                            + '&heure1=' + heure1 + '&heure2=' + heure2
                            + '&ref_b=' + $('#filtre_ref_b').val() + '&ref_f=' + $('#filtre_ref_f').val()
                            + '&ttc1=' + $('#filtre_ttc1').val() + '&ttc2=' + $('#filtre_ttc2').val()
                            + '&departement=' + $('#departement').val(),
                    success: function(data) {
                        $('#liste_reglement').html(data)
                    }
                })
            }
            function changeFormatDate(date) {
                if (date == '')
                    return date
                date = date.split('/')
                date = date[2] + '-' + date[1] + '-' + date[0]
                return date
            }
          

            </script>

